<?php
/**
 * Created by PhpStorm.
 * User: shaowei
 * Date: 2018/12/22
 * Time: 下午5:54
 */

namespace App\Http\Controllers;

use App\Http\Model\Hint;
use App\Http\Model\OutJson;

use App\Http\Services\RoomMsgServices;
use App\Http\Services\RoomScoreServices;
use App\Http\Services\RoomServicesInit;
use App\Http\Services\RoomWaitbitServices;
use Illuminate\Http\Request;


class RoomScoreController extends Controller
{
    private $services;

    public function __construct()
    {
        $this->services = new RoomScoreServices();
    }

    /**
     * 设置房间信誉分
     * @param Request $request
     */
    public function setRoomReputation(Request $request)
    {
        $roomId = $request->post("room_id", 0); //房间ID
        $score = $request->post("score", 0); //积分
        $type = $request->post("type", 0); //操作类型：1增加;2减少
        $desc = $request->post("desc", ''); //操作描述
        $adminName = $request->post("adminName", ''); //操作者昵称
        if (empty($roomId) || empty($score) || empty($type)) {
            OutJson::outJsonNoData(Hint::PARAM_ERROR);
            return;
        }

        $data = $this->services->setRoomReputation($type, $roomId, $score, $desc, $adminName);
        OutJson::outJsonResult(Hint::SUCCESS, $data);
    }

    /**
     * 信誉值更新定时器
     * 房间在一定时间内没有违规，会自动涨积分
     * @param Request $request
     */
    public function roomReputationTimer(Request $request)
    {
        $this->services->roomReputationTimer();
        OutJson::outJsonResult(Hint::SUCCESS, []);
    }

}